package com.knightboy.smartshoes.outerNavigation;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

public class RequestByGet {

    public static String getInfomation(String aurl) {
        String result = "";
        try {
            URL url = new URL(aurl);
            HttpURLConnection hc = (HttpURLConnection) url.openConnection();
            hc.setRequestMethod("GET");
            hc.setReadTimeout(2000);
            InputStream content = hc.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(content);
            byte[] b = new byte[1024];
            int len = bis.read(b);
            while (len != -1) {
                String str = new String(b, 0, len);
                result += str;
                len = bis.read(b);
            }
            bis.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (ProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
